<?php

use Illuminate\Http\Request;


/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});

//天猫精灵
Route::post('tianmao/token', 'API\TianmaoAPIController@token');
Route::post('tianmao/control','API\TianmaoAPIController@control');


//city
Route::middleware('auth:api')->get('city/{type}/{pid}', 'API\CommonAPIController@getCity');
//start_up 启动页
Route::get('startup/logos', 'API\CommonAPIController@getStartupLogo');
Route::post('mqtt/send', 'API\CommonAPIController@mqttSend');
Route::post('mqtt/subscribe', 'API\CommonAPIController@mqttSubscribe');
Route::post('mqtt/receive', 'API\CommonAPIController@mqttReceive');

Route::post('curl', 'API\CommonAPIController@curl');
Route::post('socket', 'API\CommonAPIController@socket');









//七牛
Route::get('qiniu/token', 'API\FileAPIController@getQiniuToken');
Route::post('qiniu/upload', 'API\FileAPIController@uploadFile');


//用户api
Route::resource('users', 'API\UserAPIController', ['except' => ['store','delete']]);
Route::group(['prefix' => 'users'], function () {
    Route::post('register', 'API\UserAPIController@register');
    Route::get('sms/code/{type}/{phone}', 'API\UserAPIController@getSmsCode');
    Route::post('password/modify', 'API\UserAPIController@modifyPassword');
    //获取公众列表
    Route::get('work/type','API\UserAPIController@getWorkType');
});

//支付
Route::post('pay', 'API\PayAPIController@pay');

/**
 * 阿里接口
 */

Route::group(['prefix' => 'ali'], function () {
    Route::post('product/create', 'API\AliAPIController@createProduct');
    Route::post('product/update', 'API\AliAPIController@updateProduct');
    Route::post('device/list','API\AliAPIController@getDeviceList');
    Route::post('device/register','API\AliAPIController@deviceRegister');
    Route::post('device/detail','API\AliAPIController@getDeviceDetail');
    Route::post('device/status','API\AliAPIController@getDeviceStatus');
    Route::post('topic/publish','API\AliAPIController@publishToTopic');
    Route::post('sendMessageToDevice','API\AliAPIController@sendMessageToDevice');
    Route::post('sendBroadcastMessage','API\AliAPIController@sendBroadcastMessage');
    Route::post('device/shadow/get','API\AliAPIController@getDeviceShadow');
    Route::post('device/shadow/update','API\AliAPIController@getDeviceShadow');



});


/**
 * 产品管理
 */
Route::resource('products', 'API\ProductAPIController');
/**
 * 设备管理
 */
Route::resource('devices', 'API\DeviceAPIController');

Route::group(['prefix' => 'devices'], function () {
    Route::post('{id}/sendToTopic', 'API\DeviceAPIController@sendToTopic');
    Route::post('{id}/sendToDevice', 'API\DeviceAPIController@sendToDevice');
    Route::get('{id}/shadow', 'API\DeviceAPIController@sendDeviceShadow');
});